﻿using Cysharp.Threading.Tasks;
using System.Collections.Generic;

public class Skill_2 : SkillBase
{
    private float m_PerstunSeconds;
    private float m_PoststunSeconds;
    private double m_SkillRate;
    private List<UnitEntityBase> m_Targets;

    protected override SkillArea.Base CreateArea() =>
        new SkillArea.Rectangle(this,
            (float)config.fixedParameters[2],
            (float)config.fixedParameters[3],
            (float)config.fixedParameters[4],
            (float)config.fixedParameters[5]);

    protected override void OnInit()
    {
        m_PerstunSeconds = (float)config.fixedParameters[0];
        m_PoststunSeconds = (float)config.fixedParameters[1];
        m_SkillRate = upgradableParameters[0];
    }

    protected async override UniTask OnExecute()
    {
        SkillAction.PlayAnim(entity, "chant");
        if (await SkillAction.Wait(this, m_PerstunSeconds)) return;
        SkillAction.PlayAnim(entity, "cast");
        m_Targets = area.SearchArea();
        foreach (var target in m_Targets)
        {
            SkillAction.DealDamage(entity, target, m_SkillRate);
            SkillAction.SetHated(target, entity);
        }
        SkillAction.SpawnVFX(this, (area as SkillArea.Rectangle).center);
        if (await SkillAction.Wait(this, m_PoststunSeconds)) return;
    }
}